<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.1.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"chenmenghui.gitee.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":false,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="什么是表分区分区是将一个大表,根据条件分割成若干个小表.mysql5.1开始支持表分区,5.5支持表分区的所有函数 为什么要对表进行分区 为了改善大型表以及具有各种访问模式的表的可伸缩性,客观理性和提高数据库效率  分区的一些优点包括  与单个磁盘或文件系统相比,可以存储更多的数据 通过删除与增加那些数据有关的分区,很容易地删除或增加那些数据(比如直接truncate一张表比delete wher">
<meta property="og:type" content="article">
<meta property="og:title" content="MySql表分区">
<meta property="og:url" content="https://chenmenghui.gitee.io/posts/20513.html">
<meta property="og:site_name" content="陈孟辉的学习笔记">
<meta property="og:description" content="什么是表分区分区是将一个大表,根据条件分割成若干个小表.mysql5.1开始支持表分区,5.5支持表分区的所有函数 为什么要对表进行分区 为了改善大型表以及具有各种访问模式的表的可伸缩性,客观理性和提高数据库效率  分区的一些优点包括  与单个磁盘或文件系统相比,可以存储更多的数据 通过删除与增加那些数据有关的分区,很容易地删除或增加那些数据(比如直接truncate一张表比delete wher">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2018-12-19T16:00:00.000Z">
<meta property="article:modified_time" content="2022-04-15T05:54:44.761Z">
<meta property="article:author" content="陈孟辉">
<meta property="article:tag" content="MySQL">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://chenmenghui.gitee.io/posts/20513.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>MySql表分区 | 陈孟辉的学习笔记</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/rss2.xml" title="陈孟辉的学习笔记" type="application/rss+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">陈孟辉的学习笔记</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">加油吧骚年</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-rss">

    <a href="/rss2.xml" rel="section"><i class="fa fa-rss fa-fw"></i>RSS</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://chenmenghui.gitee.io/posts/20513.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="陈孟辉">
      <meta itemprop="description" content="日积月藏，不做咸鱼。这里是陈孟辉的个人学习笔记，现就职于北京瑞友科技，负责维护企业ERP系统。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="陈孟辉的学习笔记">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          MySql表分区
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2018-12-20 00:00:00" itemprop="dateCreated datePublished" datetime="2018-12-20T00:00:00+08:00">2018-12-20</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-04-15 13:54:44" itemprop="dateModified" datetime="2022-04-15T13:54:44+08:00">2022-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/mysql/" itemprop="url" rel="index"><span itemprop="name">mysql</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/posts/20513.html#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/posts/20513.html" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="什么是表分区"><a href="#什么是表分区" class="headerlink" title="什么是表分区"></a>什么是表分区</h3><p>分区是将一个大表,根据条件分割成若干个小表.mysql5.1开始支持表分区,5.5支持表分区的所有函数</p>
<h3 id="为什么要对表进行分区"><a href="#为什么要对表进行分区" class="headerlink" title="为什么要对表进行分区"></a>为什么要对表进行分区</h3><blockquote>
<p>为了改善大型表以及具有各种访问模式的表的可伸缩性,客观理性和提高数据库效率</p>
</blockquote>
<p>分区的一些优点包括</p>
<ul>
<li>与单个磁盘或文件系统相比,可以存储更多的数据</li>
<li>通过删除与增加那些数据有关的分区,很容易地删除或增加那些数据(比如直接truncate一张表比delete where快多了)</li>
<li>一些查询可以得到极大的优化</li>
<li>通过跨多个磁盘甚至服务器来分散数据查询,来获得更高的查询吞吐量</li>
<li>MySql5.5之后支持所有函数的分区优化</li>
</ul>
<h3 id="基本分区类型"><a href="#基本分区类型" class="headerlink" title="基本分区类型"></a>基本分区类型</h3><h4 id="RANGE分区"><a href="#RANGE分区" class="headerlink" title="RANGE分区"></a>RANGE分区</h4><ul>
<li>基于属于一个给定连续区间的列值,把多行分配给分区</li>
<li>这些区间要连续且不能相互重叠,使用values less than操作符来进行定义<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">ALERT <span class="keyword">TABLE</span> titles</span><br><span class="line"><span class="keyword">partition</span> <span class="keyword">by</span> <span class="keyword">range</span>(<span class="keyword">year</span>(from_date))</span><br><span class="line">(</span><br><span class="line">  partion p01 <span class="keyword">values</span> less than (<span class="number">1985</span>),</span><br><span class="line">  partion p02 <span class="keyword">values</span> less than (<span class="number">1995</span>),</span><br><span class="line">  partion p03 <span class="keyword">values</span> less than (<span class="number">2005</span>),</span><br><span class="line">  partion p04 <span class="keyword">values</span> less than (<span class="number">2015</span>),</span><br><span class="line">  partion p05 <span class="keyword">values</span> less than (MAXVALUE),</span><br><span class="line">);</span><br></pre></td></tr></table></figure>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t1</span><br><span class="line">(</span><br><span class="line">  id   <span class="type">int</span>,</span><br><span class="line">  name <span class="type">varchar</span>(<span class="number">20</span>),</span><br><span class="line">  age  <span class="type">int</span></span><br><span class="line">)</span><br><span class="line">  <span class="keyword">PARTITION</span> <span class="keyword">BY</span> <span class="keyword">RANGE</span> (age)</span><br><span class="line">    (</span><br><span class="line">    <span class="keyword">PARTITION</span> p01 <span class="keyword">VALUES</span> LESS THAN (<span class="number">10</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p02 <span class="keyword">VALUES</span> LESS THAN (<span class="number">20</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p03 <span class="keyword">VALUES</span> LESS THAN (<span class="number">30</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p04 <span class="keyword">VALUES</span> LESS THAN (MAXVALUE)</span><br><span class="line">    );</span><br></pre></td></tr></table></figure></li>
</ul>
<h4 id="LIST分区"><a href="#LIST分区" class="headerlink" title="LIST分区"></a>LIST分区</h4><ul>
<li>类似于按RANGE分区,区别在于LIST分区是基于列值匹配一个离散值集合中的某个值来进行选择</li>
<li>LIST分区通过使用”partition by list(expr)”来实现,其中”expr”是某列值或一个基于某个列值并返回一个证书的表达式,然后通过”value in (value_list)”的方式来定义每个分区,其中”value_list”是一个通过通过逗号分隔的整数列表</li>
<li>在MySQL5.1中,list分区默认只能匹配整数表.现在5.5已经解决<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t2</span><br><span class="line">(</span><br><span class="line">  id       <span class="type">int</span>,</span><br><span class="line">  cid      <span class="type">int</span>,</span><br><span class="line">  NAME     <span class="type">VARCHAR</span>(<span class="number">20</span>),</span><br><span class="line">  pos_date datetime</span><br><span class="line">)</span><br><span class="line">  <span class="keyword">PARTITION</span> <span class="keyword">BY</span> LIST (cid)</span><br><span class="line">    (</span><br><span class="line">    <span class="keyword">PARTITION</span> p01 <span class="keyword">VALUES</span> <span class="keyword">IN</span> (<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p02 <span class="keyword">VALUES</span> <span class="keyword">IN</span> (<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p03 <span class="keyword">VALUES</span> <span class="keyword">IN</span> (<span class="number">7</span>,<span class="number">8</span>,<span class="number">9</span>)</span><br><span class="line">    );</span><br></pre></td></tr></table></figure></li>
</ul>
<h4 id="HASH分区"><a href="#HASH分区" class="headerlink" title="HASH分区"></a>HASH分区</h4><ul>
<li>基于用户定义的表达式的返回值来进行选择的分区,该表达式使用将要插入到表中的这些行的列值进行计算.这个表达式可以包含MySQL中有效的,产生非负整数值的任何表达式</li>
<li>使用HASH分区的优点在于数据分布较为均匀</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t3</span><br><span class="line">(</span><br><span class="line">  id       <span class="type">int</span>,</span><br><span class="line">  cid      <span class="type">int</span>,</span><br><span class="line">  name     <span class="type">varchar</span>(<span class="number">20</span>),</span><br><span class="line">  pos_date datetime</span><br><span class="line">)</span><br><span class="line">  <span class="keyword">PARTITION</span> <span class="keyword">BY</span> HASH (cid)</span><br><span class="line">    PARTITIONS <span class="number">4</span></span><br></pre></td></tr></table></figure>

<h4 id="linear-hash分区"><a href="#linear-hash分区" class="headerlink" title="linear hash分区"></a>linear hash分区</h4><ul>
<li>线性与常规哈希的区别在于,线性哈希功能使用的一个线性的2的幂(powers-of-two)运算规则,而常规哈希使用的时求哈希函数值的模数.</li>
<li>按照线性哈希分区的优点在于增加 删除 合并 和 拆分分区将变得更加快捷,有利于处理含有极大量(1t)数据的表.不过,mysql的线性哈希算法导致相比较常规哈希,数据可能分布的不那么均匀,容易产生”hotspot nodes”<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t3</span><br><span class="line">(</span><br><span class="line">  id       <span class="type">int</span>,</span><br><span class="line">  cid      <span class="type">int</span>,</span><br><span class="line">  name     <span class="type">varchar</span>(<span class="number">20</span>),</span><br><span class="line">  pos_date datetime</span><br><span class="line">)</span><br><span class="line">  <span class="keyword">PARTITION</span> <span class="keyword">BY</span> linear HASH (cid)</span><br><span class="line">    PARTITIONS <span class="number">4</span></span><br></pre></td></tr></table></figure></li>
</ul>
<h3 id="KEY分区"><a href="#KEY分区" class="headerlink" title="KEY分区"></a>KEY分区</h3><ul>
<li>类似于哈希分区,哈希分区使用的用户定义的表达式,而key分区的哈希函数是由mysql服务器提供.mysql簇(cluster)使用函数md5()来实现key分区;对于使用其他存储引擎的表,服务器使用其自己内部的哈希函数.这些函数时基于password()一样的运算法则</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t4</span><br><span class="line">(</span><br><span class="line">  id       <span class="type">int</span>,</span><br><span class="line">  cid      <span class="type">int</span>,</span><br><span class="line">  name     <span class="type">varchar</span>(<span class="number">20</span>),</span><br><span class="line">  pos_date datetime</span><br><span class="line">)</span><br><span class="line">  <span class="keyword">PARTITION</span> <span class="keyword">BY</span> [linear] KEY (cid)</span><br><span class="line">    PARTITIONS <span class="number">4</span>;</span><br></pre></td></tr></table></figure>

<h3 id="多列分区"><a href="#多列分区" class="headerlink" title="多列分区"></a>多列分区</h3><ul>
<li>columns关键字允许字符串和日期列作为分区定义列,同时还允许使用多个列定义一个分区</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t5</span><br><span class="line">(</span><br><span class="line">  id       <span class="type">int</span>,</span><br><span class="line">  cid      <span class="type">int</span></span><br><span class="line">)</span><br><span class="line">  <span class="keyword">PARTITION</span> <span class="keyword">BY</span> <span class="keyword">RANGE</span> COLUMNS (id, cid)</span><br><span class="line">    (</span><br><span class="line">    <span class="keyword">PARTITION</span> p01 <span class="keyword">VALUES</span> LESS THAN (<span class="number">10</span>,<span class="number">10</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p02 <span class="keyword">VALUES</span> LESS THAN (<span class="number">10</span>,<span class="number">20</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p03 <span class="keyword">VALUES</span> LESS THAN (<span class="number">10</span>,<span class="number">30</span>),</span><br><span class="line">    <span class="keyword">PARTITION</span> p04 <span class="keyword">VALUES</span> LESS THAN (<span class="number">10</span>,MAXVALUE ),</span><br><span class="line">    <span class="keyword">PARTITION</span> p05 <span class="keyword">VALUES</span> LESS THAN (MAXVALUE ,MAXVALUE )</span><br><span class="line">    );</span><br></pre></td></tr></table></figure>

<h3 id="子分区"><a href="#子分区" class="headerlink" title="子分区"></a>子分区</h3><ul>
<li>子分区是分区别中每个分区的再次分割</li>
<li>子分区可以用于特别大的表,在多个磁盘间分配数据和索引</li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/MySQL/" rel="tag"># MySQL</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/posts/43624.html" rel="prev" title="原生js触发事件">
      <i class="fa fa-chevron-left"></i> 原生js触发事件
    </a></div>
      <div class="post-nav-item">
    <a href="/posts/16099.html" rel="next" title="MySQL常见函数">
      MySQL常见函数 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E8%A1%A8%E5%88%86%E5%8C%BA"><span class="nav-number">1.</span> <span class="nav-text">什么是表分区</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%AF%B9%E8%A1%A8%E8%BF%9B%E8%A1%8C%E5%88%86%E5%8C%BA"><span class="nav-number">2.</span> <span class="nav-text">为什么要对表进行分区</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%9F%BA%E6%9C%AC%E5%88%86%E5%8C%BA%E7%B1%BB%E5%9E%8B"><span class="nav-number">3.</span> <span class="nav-text">基本分区类型</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#RANGE%E5%88%86%E5%8C%BA"><span class="nav-number">3.1.</span> <span class="nav-text">RANGE分区</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#LIST%E5%88%86%E5%8C%BA"><span class="nav-number">3.2.</span> <span class="nav-text">LIST分区</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#HASH%E5%88%86%E5%8C%BA"><span class="nav-number">3.3.</span> <span class="nav-text">HASH分区</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#linear-hash%E5%88%86%E5%8C%BA"><span class="nav-number">3.4.</span> <span class="nav-text">linear hash分区</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#KEY%E5%88%86%E5%8C%BA"><span class="nav-number">4.</span> <span class="nav-text">KEY分区</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%9A%E5%88%97%E5%88%86%E5%8C%BA"><span class="nav-number">5.</span> <span class="nav-text">多列分区</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%90%E5%88%86%E5%8C%BA"><span class="nav-number">6.</span> <span class="nav-text">子分区</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">陈孟辉</p>
  <div class="site-description" itemprop="description">日积月藏，不做咸鱼。这里是陈孟辉的个人学习笔记，现就职于北京瑞友科技，负责维护企业ERP系统。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">170</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">45</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">60</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://tool.oschina.net/uploads/apidocs/jquery/regexp.html" title="http:&#x2F;&#x2F;tool.oschina.net&#x2F;uploads&#x2F;apidocs&#x2F;jquery&#x2F;regexp.html" rel="noopener" target="_blank">正则表达式</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://www.cs.usfca.edu/~galles/visualization/Algorithms.html" title="https:&#x2F;&#x2F;www.cs.usfca.edu&#x2F;~galles&#x2F;visualization&#x2F;Algorithms.html" rel="noopener" target="_blank">算法图示</a>
        </li>
    </ul>
  </div>

      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">陈孟辉</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">204k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">3:06</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>

<script src="/js/utils.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : true,
      notify     : true,
      appId      : '9jQqXQuURk2dvsv5oVh9D0VM-gzGzoHsz',
      appKey     : 'YfjrSNHQAtj63yeNmdmrLlLw',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : '' || 'zh-cn',
      path       : location.pathname,
      recordIP   : true,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
